home *** CD-ROM | disk | FTP | other *** search
/ Delphi Programmer's Power Pack / Delphi Volume 1.iso / e_to_l / fbuilder / delphi / demos / vendorfm.pas < prev    next >
Pascal/Delphi Source File  |  1996-09-15  |  3KB  |  128 lines

  1. {* FormulaBuilder Demo           *}
  2. {* Copyright 1995 Clayton Collie *}
  3. {* All Rights Reserved           *}
  4. {*                               *}
  5.  
  6. {* First form of a Database Expression demo *}
  7. unit Vendorfm;
  8. interface
  9. uses
  10.   fbCalc,FBComp,FBDBComp,fbmisc,
  11.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  12.   StdCtrls, Forms, DBCtrls, DB, DBGrids, Buttons, DBTables, Grids, Mask,
  13.   ExtCtrls;
  14.  
  15. type
  16.   TVendorfrm = class(TForm)
  17.     ScrollBox: TScrollBox;
  18.     Label1: TLabel;
  19.     EditVendorNo: TDBEdit;
  20.     Label2: TLabel;
  21.     EditVendorName: TDBEdit;
  22.     Label3: TLabel;
  23.     EditAddress: TDBEdit;
  24.     Label4: TLabel;
  25.     EditAddress2: TDBEdit;
  26.     Label5: TLabel;
  27.     EditCity: TDBEdit;
  28.     Label6: TLabel;
  29.     EditState: TDBEdit;
  30.     Label7: TLabel;
  31.     EditZip: TDBEdit;
  32.     Label8: TLabel;
  33.     EditCountry: TDBEdit;
  34.     Label9: TLabel;
  35.     EditPhone: TDBEdit;
  36.     Label10: TLabel;
  37.     EditFAX: TDBEdit;
  38.     Label11: TLabel;
  39.     EditPreferred: TDBEdit;
  40.     DBGrid1: TDBGrid;
  41.     DBNavigator: TDBNavigator;
  42.     Panel1: TPanel;
  43.     DataSource1: TDataSource;
  44.     Panel2: TPanel;
  45.     Panel3: TPanel;
  46.     Table1: TTable;
  47.     Table2: TTable;
  48.     DataSource2: TDataSource;
  49.     ResultPanel: TPanel;
  50.     Label12: TLabel;
  51.     Table2PartNo: TFloatField;
  52.     Table2VendorNo: TFloatField;
  53.     Table2Description: TStringField;
  54.     Table2OnHand: TFloatField;
  55.     Table2OnOrder: TFloatField;
  56.     Table2Cost: TCurrencyField;
  57.     Table2ListPrice: TCurrencyField;
  58.     Table1VendorNo: TFloatField;
  59.     Table1VendorName: TStringField;
  60.     Table1Address1: TStringField;
  61.     Table1Address2: TStringField;
  62.     Table1City: TStringField;
  63.     Table1State: TStringField;
  64.     Table1Zip: TStringField;
  65.     Table1Country: TStringField;
  66.     Table1Phone: TStringField;
  67.     Table1FAX: TStringField;
  68.     Table1Preferred: TBooleanField;
  69.     Table1Dummy: TStringField;
  70.     Label13: TLabel;
  71.     ResultEdit: TEdit;
  72.     BitBtn1: TBitBtn;
  73.     BitBtn2: TBitBtn;
  74.     procedure FormCreate(Sender: TObject);
  75.     procedure BitBtn1Click(Sender: TObject);
  76.     procedure Table1CalcFields(DataSet: TDataset);
  77.   private
  78.     fCreated    : boolean;
  79.     fExpression : TDBExpression;
  80.     Procedure UpdateResults;
  81.   public
  82.     { public declarations }
  83.   end;
  84.  
  85. var
  86.   Vendorfrm: TVendorfrm;
  87.  
  88. implementation
  89. uses dbexprfm;
  90.  
  91. {$R *.DFM}
  92.  
  93. procedure TVendorfrm.FormCreate(Sender: TObject);
  94. begin
  95.   Table1.Open;
  96.   Table2.Open;
  97.   Fexpression := TDBExpression.Create(Self);
  98.   FExpression.Database := Table1.Database;
  99.   fCreated := True;
  100. end;
  101.  
  102. Procedure TVendorFrm.UpdateResults;
  103. var s : string;
  104. begin
  105.   if Assigned(FExpression) and (not FExpression.isNull) then
  106.   begin
  107.     s := FExpression.AsString;
  108.     ResultEdit.Text := s;
  109.   end;
  110. end;
  111.  
  112.  
  113. procedure TVendorfrm.BitBtn1Click(Sender: TObject);
  114. begin
  115.    if BuildDBExpression('Database Expression Demo',fExpression) then
  116.    begin
  117.      UpdateResults;
  118.    end;
  119. end;
  120.  
  121.  
  122. procedure TVendorfrm.Table1CalcFields(DataSet: TDataset);
  123. begin
  124.   UpdateResults;
  125. end;
  126.  
  127. end.
  128.